package vg.memo.util;

import com.meterware.httpunit.ClientProperties;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebLink;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;

public class WebConversationUtils {
		
	public static WebResponse getResponse(WebConversation client, WebRequest req) {
		try {
			return client.getResponse(req);
		} catch (Exception e) {
			throw new RequestFailedException(e);
		}
	}

	public static WebResponse getResponse(WebConversation client, String request) {
		try {
				return client.getResponse(request);
		} catch (Exception e) {
			throw new RequestFailedException(e);
		}
	}
	
	public static WebLink[] getLinks(WebResponse res) {
		try {
			return res.getLinks();
		} catch (Exception e) {
			throw new RequestFailedException(e);
		}
	}
	
	public static void printClientInfo(ClientProperties prop) {
		System.out.println("ApplicationCodeName ["+prop.getApplicationCodeName()+"]");
		System.out.println("ApplicationName ["+prop.getApplicationName()+"]");
		System.out.println("ApplicationVersion ["+prop.getApplicationVersion()+"]");
		System.out.println("UserAgent [" + prop.getUserAgent() +"]");
		System.out.println("AcceptCookies [" + prop.isAcceptCookies() + "]");
		System.out.println("AcceptGzip [" + prop.isAcceptGzip() + "]");
		System.out.println("AutoRedirect [" + prop.isAutoRedirect() + "]");
		System.out.println("AutoRefresh [" + prop.isAutoRefresh() + "]");
		System.out.println("IFrameSupported [" + prop.isIframeSupported() + "]");
	}
}
